shut down gracefully on SIGINT/SIGTERM and wipe temp secrets - #113
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #32.
Summary
mqdb agent startandmqdb cluster startnow install signal handlers (Ctrl-C on all platforms, SIGTERM on unix); on signal they trigger the agent's existing shutdown channel, await graceful task drain, then remove the process-scoped inline-secret temp directory (${TMPDIR}/mqdb-env-secrets-{pid}/). Previously the default handler killed the process immediately, skipping graceful shutdown and leaving0o600secret files on disk until reboot.run/startnow racebroker.run()against the shutdown channel, soMqdbAgent::shutdown()actually stops the broker instead of only signalling the auxiliary tasks (the pre-existing gap that made a CLI-only signal handler insufficient)ClusteredAgentgainsshutdown_handle()so a signal task can trigger shutdown whilerun(&mut self)holds the borrow (the cluster event loop already selects on the shutdown channel)env_secret::cleanup()removes the temp secret directory, best-effortTest plan
agent_run_task_stops_on_shutdown—runtask returns on shutdown instead of blocking on the broker (times out under the old code)cleanup_removes_process_secret_dir— temp secret dir written then removed bycleanupMQDB_PASSWD(creates the0600secret dir),kill -TERM→ process exits gracefully, secret dir removed, port releasedtest_cli_connect_timeout_against_silent_listenertiming flake excepted)